<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="common/template :: res(title='充值')">

</head>
<body style="padding-left: 5px;">
	<script type="text/javascript">
		$(function(){
			
			$('input:radio[name="userType"]').change(function() {
				userTypeAction();
			});
			$('#formSubimt').click(function(){
				var userType = $('input:radio[name="userType"]:checked').val();
				
				doRequest({
					type:'POST',
					url:'recharge',
					data:{
						depositType: $('input:radio[name="depositType"]:checked').val(),
						channelType:$('input:radio[name="channelType"]:checked').val(),
						bankCode:$('#bankCode').val(),
						ipsAcctNo:$('#ipsAcctNo').val(),
						userType:userType,
						trdAmt:$('#trdAmt').val(),
						ipsFeeType:$('input:radio[name="ipsFeeType"]:checked').val(),
						merFee:$('#merFee').val(),
						merFeeType:$('input:radio[name="merFeeType"]:checked').val(),
						taker:$('input:radio[name="taker"]:checked').val()
					}
				},function(data){
					console.log(data);
					$('#merchantID').val(data.merchantID);
					$('#sign').val(data.sign);
					$('#request').val(data.requestBody);
					$('#submitForm').submit();
				});
			});
			userTypeAction();
			bankInfo();
		});
		
		function userTypeAction(){
			var $selectedvalue = $("input[name='userType']:checked").val();

			doRequest({
				url:'users',
				data:{
					type:$selectedvalue
				}
			},function(data){
				console.log(data);
				var html ='';
				
				$(data).each(function(index,d){
					var showInfo=$selectedvalue==1?d.realName:d.enterName;
					html +=('<option value="'+d.ipsAcctNo+'">'+showInfo+'</option>');
				});
				$('#ipsAcctNo').html(html);
			});

		}
		
		
		function bankInfo(){
			doRequest({
				url:'bankcards'
			},function(data){
				console.log(data);
				var html ='<option></option>';
				
				$(data).each(function(index,d){
					var showInfo=d.bizId==1?'个人网银':'企业网银';
					html +='<option value="'+d.bankCode+'">'+d.bankName+'-'+showInfo+'</option>';
				});
				$('#bankCode').html(html);
			});
		}
	</script>
	<div class="alert alert-success toptips" role="alert" id="js_tooltips"
		style="display: none; z-index: 100;">信息展示窗口</div>


	<div class="page-header">
		<h2>
			江苏亦融在线 <small>支付调试</small>
		</h2>

	</div>
	<ol class="breadcrumb">
		<li><a href="index">首页</a></li>
		<li class="active">充值</li>
	</ol>

	<div class="form-horizontal" style="padding-left: 20px;">
		<div class="form-group">
			<label>充值类型</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="depositType" value="1" checked="checked" />普通充值
				</label> <label class="checkbox-inline"> <input type="radio"
					name="depositType" value="2" />还款充值
				</label>
			</div>
		</div>
		<div class="form-group">
			<label>渠道种类</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="channelType" value="1" checked="checked" />个人网银
				</label> <label class="checkbox-inline"> <input type="radio"
					name="channelType" value="2" />企业网银
				</label>
			</div>
		</div>
		<div class="form-group">
			<label>用户类型</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="userType" value="1" checked="checked" />个人
				</label> <label class="checkbox-inline"> <input type="radio"
					name="userType" value="2" />企业
				</label>
			</div>
		</div>
		<div class="form-group">
			<label>融资方用户</label> <select class="combobox" id="ipsAcctNo"
				style="width: 200px;">
			</select>
		</div>
		<div class="form-group">
			<label>支持银行卡号</label> <select class="combobox" id="bankCode"
				style="width: 200px;">
			</select>
		</div>



		<div class="form-group">
			<label>充值金额</label> <input type="text" class="form-control"
				id="trdAmt" value="1000" />
		</div>
		<div class="form-group">
			<label>IPS 手续费承担方</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="ipsFeeType" value="1" />平台商户
				</label> <label class="checkbox-inline"> <input type="radio"
					name="ipsFeeType" value="2" checked="checked" />平台用户
				</label>
			</div>
		</div>
		<div class="form-group">
			<label>平台手续费</label> <input type="text" class="form-control"
				id="merFee" value="0"/>
		</div>

		<div class="form-group">
			<label>平台手续费收取方式</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="merFeeType" value="1" />内扣
				</label> <label class="checkbox-inline"> <input type="radio"
					name="merFeeType" value="2" checked="checked" />外扣
				</label>
			</div>
		</div>
		<div class="form-group">
			<label>发起方</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="taker" value="1" />商户发起
				</label> <label class="checkbox-inline"> <input type="radio"
					name="taker" value="2" checked="checked" />用户发起
				</label>
			</div>
		</div>

		<div class="form-group">

			<button class="btn btn-default" id="formSubimt">提交</button>

		</div>
	</div>
	<div style="display: none;">
		<form action="http://180.168.26.114:20010/p2p-deposit/gateway.htm"
			method="post" id="submitForm" target="_blank">

			<input type="text" name="operationType" id="operationType"
				value="trade.deposit" /> <input type="text" name="merchantID"
				id="merchantID" /> <input type="text" name="sign" id="sign" /> <input
				type="text" name="request" id="request" />
		</form>
	</div>

</body>
</html>